package com.jic.market.enums;

import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/4/13
 * @description: 开参团flag 1 开团，0 参团
 * @modified By:
 * @version: V1.0
 */
public enum GrouponLaunchFlag {

    // 开参团flag 1 开团，0 参团
    GROUP_OPEN(1, "开团"),
    GROUP_JOIN(0, "参团"),
    ;

    private Integer code;

    private String value;

    GrouponLaunchFlag(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static GrouponLaunchFlag getEnumByCode(Integer code){
        EnumSet<GrouponLaunchFlag> elements = EnumSet.allOf(GrouponLaunchFlag.class);
        for(GrouponLaunchFlag enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static int getCodeByValue(String value) {
        for (GrouponLaunchFlag c : GrouponLaunchFlag.values()) {
            if (c.getValue().equals(value.trim())) {
                return c.code;
            }
        }
        return 0;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
